<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE HTML>
<html class="">
<head>
	
	<meta name="author" content="蓝凌科技">
	<meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
	<meta name="format-detection" content="telephone=no">
	<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
	<meta http-equiv="Pragma" content="no-cache" />
	<meta http-equiv="Expires" content="0" />

	<link rel="stylesheet" type="text/css" href="/Public/Api/css/sm.min.css">	
	<link rel="stylesheet" type="text/css" href="/Public/Api/css/sm-extend.min.css">	
	
	<title>帮工小哥</title>
	
	<script type="text/javascript">
	    var _root = '<?php echo ($_site_url); echo U(' / ');?>', _controller = '<?php echo ($_controller); ?>';
	</script>
	
	
	<link rel="stylesheet" type="text/css" href="/Public/Api/css/order.css">


</head>
<body>
	
	

<div class="page-group">
    <div class="page page-current">
        <form action="<?php echo U('UserAddress/saveAction');?>" method="post" class="personal-info address-add my-order">
            <div class="order-foot bar bar-standard bar-footer">
                <div class="content-block order-foot-block">
                    <div class="row">
                        <div class="col-100">
                        	<a href="#" class="button button-big button-fill button-pay" onclick="add()">确认</a>
                        </div>
                        <input type="hidden" name="type" id="type" value="<?php echo ($type); ?>"/>
                    	<input type="hidden" name="data" id="data" value="<?php echo ($data); ?>"/>
                    	<input type="hidden" name="address_id" id="address_id" value="<?php echo ($addressModel['address_id']); ?>"/>
                    	<input type="hidden" name="latitude" id="latitude" value="<?php echo ((isset($addressModel['latitude']) && ($addressModel['latitude'] !== ""))?($addressModel['latitude']):''); ?>"/>
                    	<input type="hidden" name="longitude" id="longitude" value="<?php echo ((isset($addressModel['longitude']) && ($addressModel['longitude'] !== ""))?($addressModel['longitude']):''); ?>"/>
                    	<input type="hidden" name="city" id="city" value="<?php echo ((isset($addressModel['city']) && ($addressModel['city'] !== ""))?($addressModel['city']):''); ?>"/>
                    	<input type="hidden" name="address" id="address" value="<?php echo ((isset($addressModel['address']) && ($addressModel['address'] !== ""))?($addressModel['address']):''); ?>"/>
                    </div>
                </div>
            </div>
            <div class="content ">
                <!--个人资料主体内容-->
                <ul class="address">
                    <li>
                        <span class="left">地址</span><span class="address-get"><?php echo ((isset($addressModel['address']) && ($addressModel['address'] !== ""))?($addressModel['address']):'请使用地图定位您的维修地址'); ?></span><a href="#" class="icon-map" onclick="mapapi();"></a>
                    </li>
                    <li style="position:relative;">
                    	<span class="address-details">
                    		<input type="text" placeholder="详细地址" name="name" id="name" value="<?php echo ((isset($addressModel['name']) && ($addressModel['name'] !== ""))?($addressModel['name']):''); ?>"/>
                    	</span>
                    	<a href="#" class="delete right" style="right:0.75rem"></a>
                    </li>
                </ul>
                <div class="list-block">
                    <ul>
                        <li class="contacts">
                            <a href="#" class="item-link item-content">
                                <div class="item-inner">
                                    <div class="item-title label">联系人</div>
                                    <div class="item-input">
                                        <input class="right" type="text" name="contact" id="contact"
                                        	value="<?php echo ((isset($addressModel['contact']) && ($addressModel['contact'] !== ""))?($addressModel['contact']):''); ?>" 
                                        	placeholder="您的姓名" style="text-align: right;">
                                    </div>
                                </div>
                            </a>
                        </li>
                        <li class="gender">
                            <a href="#" class="item-link item-content">
                                <div class="item-inner">
                                    <div class="item-title label">性别</div>
                                    <div class="item-input">
                                        <input type="text" placeholder="男" id="picker" name="picker" 
                                        	value="<?php if($addressModel["sex"] == 1): ?>男<?php else: ?>女<?php endif; ?>" readonly>
                                    </div>
                                </div>
                            </a>
                        </li>
                        <li class="contact-tel">
                            <a href="#" class="item-link item-content">
                                <div class="item-inner">
                                    <div class="item-title label">联系电话</div>
                                    <div class="item-input">
                                        <input class="right" type="text" name="telphone" id="telphone" 
                                        	value="<?php echo ($addressModel['telphone']); ?>" placeholder="联系电话" style="text-align: right;">
                                    </div>
                                    <!--<div class="right phone-num"></div>-->
                                </div>
                            </a>
                        </li>
                    </ul>
                </div>
            </div>
        </form>
    </div>
</div>




	<!-- 底部
================================================== -->
<footer>
</footer>
<script type="text/javascript">
    (function(){
        var ThinkPHP = window.Think = {
            "ROOT"   : "", //当前网站地址
            "APP"    : "/api.php?s=", //当前项目地址
            "PUBLIC" : "/Public", //项目公共目录地址
            "DEEP"   : "<?php echo C('URL_PATHINFO_DEPR');?>", //PATHINFO分割符
            "MODEL"  : ["<?php echo C('URL_MODEL');?>", "<?php echo C('URL_CASE_INSENSITIVE');?>", "<?php echo C('URL_HTML_SUFFIX');?>"],
            "VAR"    : ["<?php echo C('VAR_MODULE');?>", "<?php echo C('VAR_CONTROLLER');?>", "<?php echo C('VAR_ACTION');?>"]
        }
    })();
    
</script>
<script src="/Public/Api/js/zepto.min.js" type="text/javascript">
</script>
<script type="text/javascript">
//坑死人的配置项
//若不加此配置，则所有页面均使用 js 和 css 缓存
$.config = {
   	router: false
}
</script>
<script src="/Public/Api/js/sm.min.js" type="text/javascript">
</script>
<script src="/Public/Api/js/sm-extend.min.js" type="text/javascript">
</script>
<script src="/Public/Api/js/think.js" type="text/javascript">
</script>


<script src="/Public/Api/js/order.js" type="text/javascript"></script>
<script type="text/javascript">

function mapapi(){
	
	var type = $("#type").val();
	var addressID = $("#address_id").val();
	var callback = 'http://' + window.location.host
				+ Think.U('UserAddress/editAction', '&type='+type+'&address_id='+addressID);

	window.location.href = 'http://apis.map.qq.com/tools/locpicker?search=1&type=0&backurl=' + callback 
							+ '&key=WQJBZ-F5OKV-4HPPF-UHKNQ-7WSGV-QCBB3&referer=myapp';
}

function add(){
	
	var latitude = $("#latitude").val();
	var longitude = $("#longitude").val();
	var contact = $("#contact").val();
	var telphone = $("#telphone").val();
	var name = $("#name").val();
	
	if(!latitude || !longitude){
		$.alert('请选择地址');
		return false;
	}else if(!contact){
		$.alert('请填写联系人姓名');
		return false;
	}else if(!(/^1((3|4|5|8){1}\d{1}|70)\d{8}$/.test(telphone))){
		$.alert("手机号码格式有误，请确认");  
		return false;
	}else if(!name){
		$.alert("请填写详细地址");  
		return false;
	}else{
		$(document).find('form').submit();
	}
}

</script>

<!-- 用于加载js代码 -->

</body>
</html>